package starfire.ftp;

import java.util.*;

/**
 * @author tianshi
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class FtpCommandSupport {
  private Vector commandEvents = null;

  public FtpCommandSupport() {
    commandEvents = new Vector();
  }

  public void addFtpCommandListener(FtpCommandListener listener) {
    commandEvents.add(listener);
  }

  public void removeFtpCommandListener(FtpCommandListener listerner) {
    commandEvents.remove(listerner);
  }

  public void fireOnConnect(FtpEvent e) {
    int count = commandEvents.size();
    for (int i = 0; i < count; i++) {
      ( (FtpCommandListener) commandEvents.get(i)).onConnect(e);
    }
  }

  public void fireOnSendCommand(FtpEvent e) {
    int count = commandEvents.size();
    for (int i = 0; i < count; i++) {
      ( (FtpCommandListener) commandEvents.get(i)).onSendCommand(e);
    }
  }

  public void fireOnRecvReply(FtpEvent e) {
    int count = commandEvents.size();
    for (int i = 0; i < count; i++) {
      ( (FtpCommandListener) commandEvents.get(i)).onRecvReply(e);
    }
  }

  public void fireOnError(FtpEvent e) {
    int count = commandEvents.size();
    for (int i = 0; i < count; i++) {
      ( (FtpCommandListener) commandEvents.get(i)).onError(e);
    }
  }

  public void fireDisconnect(FtpEvent e) {
    int count = commandEvents.size();
    for (int i = 0; i < count; i++) {
      ( (FtpCommandListener) commandEvents.get(i)).onDisconnect(e);
    }
  }
}
